home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / JAVA_UTL / C2JAVA / README < prev    next >
Encoding:
Text File  |  1996-04-07  |  3.9 KB  |  100 lines

  1. #############################################################################
  2.  
  3. c2j,  96/04/04,  Chris Laffra
  4.  
  5. Copyright (c) 1995-1996 Morgan Stanley & Co., Inc. All Rights Reserved.
  6.  
  7. Permission to use, copy, modify, and distribute this software
  8. and its documentation for NON-COMMERCIAL purposes and without
  9. fee is hereby granted provided that this copyright notice
  10. appears in all copies. Please contact email: laffra@ms.com
  11. for further copyright and licensing information.
  12.  
  13. MORGAN STANLEY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
  14. OF THIS SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  15. TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  16. PARTICULAR PURPOSE, OR NON-INFRINGEMENT. MORGAN STANLEY SHALL NOT BE LIABLE
  17. FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  18. DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  19.  
  20. #############################################################################
  21.  
  22. c2j is a C++ to Java translator that translates C++ code to Java code.
  23. The input must consist of:
  24.  
  25.    - one .H file, containing one or more C++ class definitions.
  26.    - one .C file, containing all method bodies referenced in the .H file.
  27.  
  28. c2j is basically a shell-script that calls sed, a C++-to-Java translator,
  29. and the C pre-processor to do all the weaving of moving methods into one
  30. Java class definition.
  31.  
  32. This parser currently uses a shell script and a Unix utility called "sed".
  33. When you have access to Unix utilities on a Windows PC (like the MKS
  34. toolkit), the parser could also be used. 
  35. On Unix, and Windows NT/95 use the following command to make the parser:
  36.  
  37.     make
  38.  
  39.  
  40. Different problems that are tackled by this parser:
  41.  
  42.    - C++ can have a header file with a class declaration and a member
  43.      function given in another file (typically a .C or .cpp file),
  44.      Java has all the methods "inlined" in the class definition. 
  45.  
  46.    - Data types are incompatible (unsigned versus int, for instance)
  47.  
  48.    - Pointer references (->) need to be translated into refs (.)
  49.  
  50.    - Access (public,protected,private) is done by region in C++, and
  51.      is per method in Java.
  52.  
  53.    - Print statements to cerr and cout, which are to be translated into 
  54.      calls to System.out.print, and System.err.print.
  55.  
  56.    - Statements with "delete object;" need to be translated into
  57.      "object = null;" to render a similar effect. Note that these 
  58.      assignments are not necessary at all in a destructor, as we will
  59.      lose the reference to the object automatically.
  60.  
  61.    - Overloaded operators in a class definition are meaningless in Java.
  62.      
  63.    - C++ has multiple inheritance. Java has single inheritance and
  64.      interfaces. In the case of multiple inheritance, we need to make
  65.      a decision.
  66.  
  67. Still to be done:
  68.  
  69.    - Variable declarations on the stack are not recognized and handled.
  70.  
  71.    - Overloaded operators in the code. 
  72.  
  73.    - Templates.
  74.  
  75.    - Global variables are collected and put into the first class found
  76.      in the .H file. Something goes wrong during collection or writing,
  77.      and this class might not be the right location after all.
  78.  
  79.    - Sometimes the parser has problems with method parameters (especially
  80.      with constructor). Keep the .H and .C file handy...
  81.  
  82.    - Documentation (no time...)
  83.  
  84. It translates roughly about 85-95 percent of the code correctly. It saves
  85. me a lot of editing time (inlining all methods, translating simple types,
  86. removing &'s everywhere, changing -> into ., etc. 
  87. Just run it and see what it does for you...
  88.  
  89. We have decided to put this parser in the public domain. Use it at your
  90. own risk, and if you make any changes (especially improvements), tell us!
  91.  
  92. We hope that this utility is useful for you and the rest of the Java
  93. community.
  94.  
  95. Chris Laffra
  96. -------------------------------------------------------------------
  97. Morgan Stanley, 750 Seventh Avenue (between 49 & 50), NYC, NY 10019
  98. Email: laffra@ms.com,   Tel: (212) 762 2223,    Fax: (212) 762 0520
  99. -------------------------------------------------------------------
  100.